package com.jxdinfo.hussar.cloud.module.example.tjjc.towernotice.controller;

import com.jxdinfo.hussar.cloud.module.example.tjjc.towernotice.vo.AppTowerNoticeDetailVO;
import com.jxdinfo.hussar.cloud.module.example.tjjc.towernotice.vo.TowerNoticeSearchVO;
import com.jxdinfo.hussar.cloud.module.example.tjjc.towernotice.vo.TowerNoticeVO;
import com.jxdinfo.hussar.support.mp.base.controller.HussarBaseController;
import org.springframework.web.bind.annotation.*;
import com.jxdinfo.hussar.support.audit.core.annotations.AuditLog;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.jxdinfo.hussar.support.audit.core.enums.AuditEventGrade;
import com.jxdinfo.hussar.support.audit.core.enums.AuditEventType;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jxdinfo.hussar.cloud.module.example.tjjc.towernotice.service.TowerNoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import com.jxdinfo.hussar.cloud.module.example.tjjc.towernotice.vo.TowerNoticePageVO;
import com.jxdinfo.hussar.cloud.module.example.tjjc.towernotice.model.TowerNotice;
import com.jxdinfo.hussar.platform.core.base.apiresult.ApiResponse;

import java.util.List;

/**
 * 塔机异常通知控制器
 */
@RestController(value = "tjjc.towernotice.TowerNoticeController")
@AuditLog(moduleName = "塔机异常通知")
@RequestMapping(value = "/tjjc/towerNotice")
public class TowerNoticeController extends HussarBaseController<TowerNotice, TowerNoticeService> {

    private static final Logger logger = LoggerFactory.getLogger(TowerNoticeController.class);

    @Autowired
    private TowerNoticeService towerNoticeService;

    /**
     * 分页查询塔机异常通知
     *
     * @param towerNoticeSearchVO 分页对象
     * @return 查询结果
     */
    @AuditLog(moduleName = "塔机异常通知", eventDesc = "表格查询", eventGrade = AuditEventGrade.SERVICE_LOG_TYPE, evnetType = AuditEventType.QUERY)
    @PostMapping("findByPage")
    public ApiResponse<TowerNoticePageVO> findByPage(@RequestBody TowerNoticeSearchVO towerNoticeSearchVO) {
        //todo 没有获取项目编号工具类
        return towerNoticeService.findByPage(towerNoticeSearchVO);
    }

    /**
     * 塔机异常通知条件查询
     *
     * @param towerNoticeSearchVO 分页对象
     * @return 查询结果
     */
    @AuditLog(moduleName = "塔机异常通知", eventDesc = "表格查询", eventGrade = AuditEventGrade.SERVICE_LOG_TYPE, evnetType = AuditEventType.QUERY)
    @PostMapping("findByList")
    public ApiResponse<List<TowerNoticeVO>> findByList(@RequestBody TowerNoticeSearchVO towerNoticeSearchVO) {
        //todo 没有获取项目编号工具类
        return towerNoticeService.findByList(towerNoticeSearchVO);
    }

    /**
     * 移动端-分页获取塔机告警通知
     *
     * @param towerNoticeSearchVO 分页对象
     * @return 查询结果
     */
    @AuditLog(moduleName = "塔机异常通知", eventDesc = "表格查询", eventGrade = AuditEventGrade.SERVICE_LOG_TYPE, evnetType = AuditEventType.QUERY)
    @PostMapping("findMobileByPage")
    public ApiResponse<TowerNoticePageVO> findMobileByPage(@RequestBody TowerNoticeSearchVO towerNoticeSearchVO) {
        //todo 没有获取项目编号工具类
        return towerNoticeService.findMobileByPage(towerNoticeSearchVO);
    }

    /**
     * 移动端-获取塔机告警通知详情
     *
     * @param noticeId
     * @return 查询结果
     */
    @AuditLog(moduleName = "塔机异常通知", eventDesc = "表格查询", eventGrade = AuditEventGrade.SERVICE_LOG_TYPE, evnetType = AuditEventType.QUERY)
    @GetMapping("findTowerNoticeDetail")
    public ApiResponse<AppTowerNoticeDetailVO> findTowerNoticeDetail(@RequestParam("noticeId") String noticeId) {
        //todo 没有获取项目编号工具类
        String projectCode = "";
        return towerNoticeService.findTowerNoticeDetail(noticeId,projectCode);
    }

    /**
     * 塔机异常通知新增
     *
     * @param towerNoticeSearchVO 分页对象
     * @return 查询结果
     */
    @AuditLog(moduleName = "塔机异常通知", eventDesc = "表格查询", eventGrade = AuditEventGrade.SERVICE_LOG_TYPE, evnetType = AuditEventType.QUERY)
    @PostMapping("add")
    public ApiResponse<String> add(@RequestBody TowerNoticeSearchVO towerNoticeSearchVO) {
        //todo 没有获取项目编号工具类
        return towerNoticeService.add(towerNoticeSearchVO);
    }

    /**
     * 塔机异常通知修改
     *
     * @param towerNoticeSearchVO 分页对象
     * @return 查询结果
     */
    @AuditLog(moduleName = "塔机异常通知", eventDesc = "表格查询", eventGrade = AuditEventGrade.SERVICE_LOG_TYPE, evnetType = AuditEventType.QUERY)
    @PostMapping("update")
    public ApiResponse<String> update(@RequestBody TowerNoticeSearchVO towerNoticeSearchVO) {
        //todo 没有获取项目编号工具类
        return towerNoticeService.updateTowerNotice(towerNoticeSearchVO);
    }

    /**
     * 移动端-塔机异常通知一键已读
     *
     * @return 查询结果
     */
    @AuditLog(moduleName = "塔机异常通知", eventDesc = "表格查询", eventGrade = AuditEventGrade.SERVICE_LOG_TYPE, evnetType = AuditEventType.QUERY)
    @PostMapping("updateAllNoticeReadStatus")
    public ApiResponse<String> updateAllNoticeReadStatus() {
        //todo 没有获取项目编号工具类
        String tyProjectCode = "";
        return towerNoticeService.updateAllNoticeReadStatus(tyProjectCode);
    }

    /**
     * 塔机异常通知删除
     *
     * @param towerNoticeSearchVO 分页对象
     * @return 查询结果
     */
    @AuditLog(moduleName = "塔机异常通知", eventDesc = "表格查询", eventGrade = AuditEventGrade.SERVICE_LOG_TYPE, evnetType = AuditEventType.QUERY)
    @PostMapping("deleteById")
    public ApiResponse<String> deleteById(@RequestBody TowerNoticeSearchVO towerNoticeSearchVO) {
        //todo 没有获取项目编号工具类
        return towerNoticeService.deleteById(towerNoticeSearchVO);
    }
}
